<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\JjrProjectHouse */

$this->title = $model['name'];
$this->params['breadcrumbs'][] = ['label' => 'Jjr Project Houses', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="jjr-project-house-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('更新', ['update', 'id' => $model['id'], ['class' => 'btn btn-primary']]) ?>
        <?= Html::a('删除', ['delete', 'id' => $model['id'], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            [
                'attribute' =>'project_name','label'=>'所属项目'],
            [ 'attribute'=>'name','label'=>'户型名称'],
            [ 'attribute'=>'type','label'=>'户型类型'],
            [ 'attribute'=>'area','label'=>'户型大小（单位/平方米）'],

            [
                'attribute' => 'main_pic',
                'value' => function($model) {//使用匿名函数格式化（参数为当前模型对象），也可以在模型类中定义该方法
                    $pic = \backend\models\Picture::findOne($model['main_pic']);
                    $path = \yii\helpers\Url::to('@storageUrl/image/'.$pic['path'],true);
                    return Html::img($path,['width'=>'200px','height'=>'100px']);
                },
                'format'=>'raw',
                'label'=>'户型主图'
            ],
            [ 'attribute'=>'description','label'=>'户型描述'],

            [ 'attribute'=>'management_type','label'=>'物业类型'],
             [ 'attribute'=>'struct','label'=>'户型结构'],
              [ 'attribute'=>'direction','label'=>'朝向'],
               [ 'attribute'=>'deal_limit','label'=>'最早成交'],
                 [ 'attribute'=>'open_limit','label'=>'最早开盘'],
                   [ 'attribute'=>'advantage','label'=>'优势'],
                     [ 'attribute'=>'price','label'=>'价格'],

            [ 'attribute'=>'create_time','label'=>'创建时间'],
            [ 'attribute'=>'update_time','label'=>'更新时间'],

        ],
    ]) ?>

</div>
<!-- 定义数据块 -->
<?php $this->beginBlock('test'); ?>
jQuery(document).ready(function() {
highlight_subnav('jjr-project-house/index'); //子导航高亮
});
<?php $this->endBlock() ?>
<!-- 将数据块 注入到视图中的某个位置 -->
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>
